package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.*;

@Mapper
public interface ShoppingCartMapper {
    /**
     *  动态条件查询，购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 插入购物车信息
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     *  根据 id 修改 商品数量
     * @param shoppingCart
     */
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void update(ShoppingCart shoppingCart);

    /**
     * 清空用户  购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void delete(Long userId);
}
